<?php

defined('BASEPATH') OR exit('No direct script access allowed');

class Home extends Base_Controller {

    public $httpcode = [
        'errno' => 200,
        'error' => '连接成功'
    ];

    public function index() {
        $this->load->view('public/head');
        $this->load->view('pages/index');
    }

    public function dashboard() {
        $query = $this->db->select('*')->get('qbjh_webconfig');
        $webconfig = $query->result_array();
        $webinfo = [];
        foreach ($webconfig as $k => $rows) {
            $webinfo[$rows['en_name']] = $rows;
        }
        $this->data['webinfo'] = $webinfo;
        $this->load->view('public/head', $this->data);
        $this->load->view('pages/webinfo');
    }

    public function updateConfig() {
        $configlist = $this->input->post();
        foreach ($configlist as $k => $rows) {
            $this->db->where("en_name='{$k}'")->update('qbjh_webconfig', ['value' => $rows]);
        }
        redirect('/home/dashboard');
    }

}
